package com.welsy.usermgt.utils
{
	import mx.collections.ArrayCollection;
	import com.welsy.usermgt.vo.UserVO;
	
	public class UserVOArrayHandle
	{
		
		
		/**
		 * Add all the element avoiding duplicate UserVO
		 * It operates in such a way that the list is scanned for copies of elements to be added
		 **/
		public static function addUserVONoDuplicates(adding : ArrayCollection, base : ArrayCollection) : void {
    			
    		if(adding == null || base == null) return;
    		
    		for(var j : int = 0; j<adding.length; j++) {
    			for(var k : int = 0; k<base.length; k++) {
    				var a : UserVO = UserVO(adding[j]);
    				var b : UserVO = UserVO(base[k]);
    				if(int(a.SubSystemId) == int(b.SubSystemId)) {
    					adding.removeItemAt(j); j--;
    					break;
    				}
    			}
    		}
    		
    		for each(var add : UserVO in adding) {
    			base.addItem(add);
    		}
    	}
	}
}